package interview;

import java.util.*;

public class Interview06 {
    static class Test{
        private Integer i;

        public Test(Integer i){
            this.i = i;
        }
    }
    public static void main(String[] args) {
        /**
         * 什么是hashcode？它属于哪个类的方法？
         *java.util.Object
         * 什么是hash冲突？写一个hash冲突的案例
         */
        System.out.println("AA".hashCode());
        System.out.println("Aa".hashCode());
        System.out.println("BB".hashCode());

        Set<Integer> hashCodeSet = new HashSet<>();
        for (int i = 1; i <= 10000 *20 ; i++) {
            Test test = new Test(i);
            if(hashCodeSet.contains(test.hashCode())){
                System.out.println("第"+i+"次的hashcode重复了，值为："+test.hashCode());
            }else {
                hashCodeSet.add(test.hashCode());
            }
        }
    }
}
